package com.zsk.shop.controller.h5;

import com.zsk.shop.common.annotion.NoPermission;
import com.zsk.shop.common.base.BaseResponse;
import com.zsk.shop.common.utils.HttpContext;
import com.zsk.shop.model.results.AppUserDecodeResult;
import com.zsk.shop.service.ShopUserService;
import com.zsk.shop.service.WxDecodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ljh
 * @create 2022/01/13 16:48
 */
@RestController
@Api(tags = "H5通用接口")
@RequestMapping("/h5")
public class H5Controller {

    @Resource
    private WxDecodeService wxDecodeService;

    /**
     * 前端获取签名
     *
     * @param url
     * @return
     */
    @NoPermission
    @ApiOperation(value = "JS-SDK使用权限获取签名")
    @GetMapping(value = "/grant/getJsApiTicket.do")
    public BaseResponse getJsApiTicket(String url) {
        return wxDecodeService.getJsApiTicket(url);
    }

    @NoPermission
    @ApiOperation(value = "微信移动端授权登录-公众号登录")
    @GetMapping(value = "/grant/weChat/jsDecode.do")
    @ApiImplicitParam(name = "code", value = "code")
    public BaseResponse<AppUserDecodeResult> wxJsDecode(String code) {
        return wxDecodeService.wxJsDecode(code);
    }

}
